import { ListNode } from "./ListNode.mjs";
/**
 * https://leetcode.cn/problems/palindrome-linked-list/description/?envType=study-plan-v2&envId=top-100-liked
 * @param {ListNode} head
 * @return {boolean}
 */
var isPalindrome = function (head) {
  if (!head) return false;
  let arr = [];
  while (head) {
    arr.push(head.val);
    head = head.next;
  }
  let left = 0,
    right = arr.length - 1;
  while (left < right) {
    if (arr[left] != arr[right]) return false;
    left++;
    right--;
  }
  return true;
};

const node = new ListNode(1, new ListNode(2));
console.log(isPalindrome(node));
